function [ Yhat ] = adaboost_test(boost, Xtest)
% Generates predictions for AdaBoost on new data.
%
% Usage:
%
%   TEST_ERR = adaboost_test(BOOST, YTEST)
%
% Returns the predictions by Adaboost given a weighted combination of weak
% learners stored in the struct BOOST. 

% Compute test error and margin
Yhat = zeros(size(Xtest, 1), 10);

T = numel(boost.dt); 

% intialize vectors 
%test_err = zeros(1, T);
% margins = cell(1, T); 

for t = 1:T
    
    % y_hat(t) = sum upto t (alpha_t * scores)
    Yhat = Yhat + boost.alpha(t)*dt_test_multi(boost.dt{t}, Xtest); 
    
    % training error: (1/n) sum (yi != final_classifier(x_i))
    %test_err(t) = ( 1/numel(Ytest) )*sum( Ytest ~= sign(Yhat) ); 
    
    % marign as per the formula given in the pdf 
    % margins{t} = ( 1/sum( boost.alpha(1:t) ) )*( Yhat.*Ytest ); 
end
